#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;
struct ListNode
{
    int val;
    ListNode *next;
    ListNode(int val = 0) : val(val){};
};
class cList
{
private:
    ListNode *head;
    int length;

public:
    cList(int length = 0) : length(length)
    {
        if (length < 0)
            return;
        head = new ListNode();
        ListNode *tmp = head;
        for (int i = 0; i < length; ++i)
        {
            ListNode *p = new ListNode(i + 1);
            tmp->next = p;
            tmp = p;
            p->next = head;
        }
    }
    void delNode(int index)
    {
        if (index <= 0 || index > length)
            return;
        ListNode *p = head;
        ListNode *tmp = p;
        for (int i = 0; i <= index - 1; ++i)
        {
            tmp = p;
            p = p->next;
        }
        tmp->next = p->next;
        delete p;
        length--;
    }
    void show()
    {
        ListNode *ptr = head->next;
        while (ptr != nullptr && ptr != head)
        {
            printf(" %d", ptr->val);
            ptr = ptr->next;
        }
        printf("\n");
    }
};
int main()
{
    cList list = *new cList(10);
    list.show();
    for (int i = 10; i >= 1; --i)
    {
        list.delNode(i);
        list.show();
    }
    return 0;
}